package com.zsk.shop.controller.gop;

import com.zsk.shop.common.base.BaseResponse;
import com.zsk.shop.model.params.AddBannerParams;
import com.zsk.shop.model.params.EditBannerParams;
import com.zsk.shop.model.params.GopBannerListParams;
import com.zsk.shop.service.ShopBannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Administrator
 */
@RestController
@Api(tags = "ShopBanner管理")
@RequestMapping("/gop/banner")
public class GopBannerController {

    @Autowired
    private ShopBannerService bannerService;

    @ApiOperation("GOP新增banner")
    @PostMapping("/addBanner.do")
    public BaseResponse addBanner(@RequestBody AddBannerParams params) {
        return bannerService.addBanner(params);
    }

    @ApiOperation("GOP轮播图列表")
    @GetMapping("/mcpBannerList.do")
    @ApiImplicitParams({@ApiImplicitParam(name = "name", value = "名称"),
            @ApiImplicitParam(name = "isShow", value = "是否显示"),
            @ApiImplicitParam(name = "limit"), @ApiImplicitParam(name = "page")})
    public BaseResponse mcpBannerList(String name,  Boolean isShow) {
        GopBannerListParams params = GopBannerListParams.builder().name(name).isShow(isShow).build();
        return bannerService.mcpBannerList(params);
    }

    @ApiOperation("GOPBanner详情")
    @GetMapping("/bannerDetail.do")
    @ApiImplicitParam(name = "id", value = "id编号")
    public BaseResponse bannerDetail(Long id) {
        return bannerService.bannerDetail(id);
    }

    @ApiOperation("GOP修改banner")
    @PostMapping("/bannerUpdate.do")
    public BaseResponse editBanner(@RequestBody EditBannerParams params) {
        return bannerService.bannerUpdate(params);
    }

    @ApiOperation("GOP修改是否禁用（显示）")
    @GetMapping("/changeShowByBannerId.do")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "banner编号"),
            @ApiImplicitParam(name = "toShow", value = "true-解禁（会显示）,false-禁用(不会显示)")})
    public BaseResponse changeShowByBannerId(Long id, Boolean toShow) {
        return bannerService.changeShowByBannerId(id, toShow);
    }

    @ApiOperation("GOP置顶banner")
    @GetMapping("/setTopByBannerId.do")
    @ApiImplicitParam(name = "id", value = "id编号")
    public BaseResponse setTopByBannerId(Long id) {
        return bannerService.setTopByBannerId(id);
    }

    @ApiOperation("GOP删除轮播图")
    @GetMapping("/deleteBannerById.do")
    @ApiImplicitParam(name = "id", value = "id编号")
    public BaseResponse deleteBannerById(Long id) {
        return bannerService.deleteBannerById(id);
    }

    @ApiOperation("GOP轮播图类型列表")
    @PostMapping("/getBannerType.do")
    public BaseResponse getBannerType() {
        return bannerService.getBannerType();
    }

}
